/* $Id: Database.java 63 2010-02-14 13:52:34Z aaron.day $ */
package org.crazydays.gameplan.db;


import java.io.Serializable;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.crazydays.gameplan.map.GameMap;

/**
 * Database
 */
public class Database
    implements Serializable
{
    /** serial version uid */
    public final static long serialVersionUID =
        "$Id: Database.java 63 2010-02-14 13:52:34Z aaron.day $".hashCode();

    /** logger */
    protected static Logger LOGGER = LoggerFactory.getLogger(Database.class);

    /** name */
    protected String name = "untitled";

    /** maps */
    protected Set<GameMap> gameMaps = new TreeSet<GameMap>();

    /**
     * Set name.
     * 
     * @param name Name
     */
    public void setName(String name)
    {
        this.name = name;
    }

    /**
     * Get name.
     * 
     * @return Name
     */
    public String getName()
    {
        return name;
    }

    /**
     * Get game maps.
     * 
     * @return GameMaps
     */
    public Set<GameMap> getGameMaps()
    {
        return Collections.unmodifiableSet(gameMaps);
    }

    /**
     * Add game map.
     * 
     * @param gameMap GameMap
     */
    public void addGameMap(GameMap gameMap)
    {
        gameMaps.add(gameMap);
    }

    /**
     * Get game map by name.
     * 
     * @param name Name
     * @return GameMap
     */
    public GameMap getGameMap(String name)
    {
        for (GameMap gameMap : gameMaps) {
            if (gameMap.getName().equals(name)) {
                return gameMap;
            }
        }

        return null;
    }
}
